Skip to content

[GRDM-63966] Python 3.13・依存ライブラリの更新と unoserver コンテナの分離(第1段階) - #9

Open
miyamoto83 wants to merge 229 commits into
RCOSDP:developfrom
miya-biz:feature/vuln-remediation-cos-wb
Open

miyamoto83 wants to merge 229 commits into
RCOSDP:developfrom
miya-biz:feature/vuln-remediation-cos-wb

Conversation

@miyamoto83

@miyamoto83 miyamoto83 commented Oct 23, 2026 •

Copy link
Copy Markdown

Ticket

GRDM-63966

Purpose

Python と依存ライブラリを更新し、既知の脆弱性を解消する。第 1 段階として CenterForOpenScience/modular-file-renderer 26.2.1 と waterbutler 26.6.1 の依存構成に合わせ、リポジトリに同梱していたブラウザ側ライブラリを見直す。RDM-waterbutler の更新に合わせて、waterbutler に関わる依存の扱いを見直す第 2 段階を別 PR で行う。

Changes

  • Python 3.5/Debian Buster を Python 3.13/Debian Trixie に更新し、依存ライブラリの管理を Poetry に移行した。CenterForOpenScience/modular-file-renderer 26.2.1 をマージし、RDM 固有の変更は維持した。
  • waterbutler の依存を CenterForOpenScience/waterbutler 26.6.1 に固定し、共有する依存(aiohttp、tornado、celery 等)の版はそれに合わせた。
  • Dockerfile をマルチステージ化し、ビルド用パッケージと pip を実行イメージから除外した。
  • LibreOffice を Ubuntu 26.04 ベースの unoserver イメージ(Dockerfile.unoserver)に分離し、Office 系ファイルの変換は Celery ワーカー経由で unoserver に依頼する方式に統一した。pydocx による docx レンダラは削除した。
  • Celery ワーカーの control_exchange を分離し、同一 RabbitMQ を共有する他アプリケーションの制御メッセージを受け取らないようにした。
  • HTTP サーバーにリクエスト本文(64KB)とヘッダ(32KB)の上限を設定した。tornado 6.5.1 の既知の脆弱性への緩和で、tornado の更新は第 2 段階で行う。
  • Pillow、nbconvert、mistune、Jinja2、Pygments、ipython、pyasn1 ほかをセキュリティ修正版に更新し、CenterForOpenScience 由来の不具合(OSF プロバイダのリダイレクト、HTTP プロバイダのレスポンス処理、aiohttp セッションの生成)を修正した。
  • CI のユニットテストをマルチステージ化後のビルド段イメージで実行するようにし、unoserver の結合テストと、mfr と unoserver 両イメージの Trivy 検査を追加した。
  • Celery の結果バックエンドを、タスクごとに結果キューを作る celery-amqp-backend に変更した。Celery 5 で amqp の代替とされる rpc:// はクライアント 1 本の返信キューに結果を集め、前のタスクの結果が ack されずに残るため、RabbitMQ の consumer_timeout(既定 30 分)でチャネルが閉じられ、その直後の変換要求が 1 回失敗する。移植前(Celery 4 の amqp)と同じ動きに戻し、既定値を固定するテストを追加した。
  • リポジトリに同梱していたブラウザ側ライブラリ(jQuery、Bootstrap、jquery-mousewheel、PDF.js、SlickGrid)を npm 管理に移した。版は package.json と package-lock.json で宣言し、Docker ビルド中に invoke assets で配信用の静的ディレクトリへ配置する。テンプレートとスタイルシートが参照するファイルの実在を確かめるテストを追加した。
  • PDF.js を 6.5.438、jQuery を 3.7.1、Bootstrap を 3.4.1、SlickGrid を 2.4.45 に更新した。PDF ビューアは PDF.js 6.5.438 の汎用ビューア(legacy ビルド)に置き換え、PDF 内スクリプトの実行と注釈の編集機能は無効にした。
  • npm から導入できない同梱ライブラリ(jQuery Zoom、pv とその gl-matrix、JSC3D)を CycloneDX SBOM(vendored-libraries.cdx.json)に宣言し、イメージ検査の対象に含めた。
  • どのテンプレートからも読み込まれていない静的ファイル(旧版の pdf.js、GLmol、three.js ほか)と、エントリポイントが登録されていない svg 拡張を削除した。
  • README から、Poetry の構成では起こらない Known issues の節を削除した。

Side effects

  • Office 系ファイルのプレビューに MFR の Celery ワーカーと unoserver コンテナが必要になる。unoconv コンテナは使用しない。
  • docx は unoserver で PDF に変換して表示する。
  • 実行イメージに pip と Poetry は含まれない。
  • PDF のプレビューが PDF.js 6.5.438 のビューアの画面になる。PDF ビューアの hypothesis 連携(ENABLE_HYPOTHESIS)と Google Analytics の埋め込みは削除した。
  • ブラウザ側ライブラリはリポジトリに含まれない。ローカルで起動する場合は、事前に npm ci --omit=optional と invoke assets を実行する。

QA Notes

  • CI: 実行 43172078202(ユニットテスト 248 件、flake8、unoserver 結合テスト、mfr と unoserver 両イメージの Trivy 検査を含む)
  • E2E: miya-biz/RDM-e2e-test-nb feature/mfr-python313(282bffb)で、本ブランチからビルドした MFR・unoserver イメージと公開版 WaterButler(niicloudoperation/rdm-waterbutler:latest)を指定して実行。実行 43172154693 は WEKO 以外の 12 ジョブ中 9 成功。ファイルプレビュー(txt、png、jpg、pdf、docx、pptx、csv、xlsx、webm)を含む User Tests は成功。失敗 3 件(Metadata、Wiki、Migration 20250906)は MFR を経由しない。
  • 表(csv、xlsx)、画像、分子構造(pdb)、3D モデル、PDF の各ビューアは、Playwright(Chromium)のスクリプトで更新前後のライブラリに同じ操作(並べ替え、列幅の変更、拡大、検索、印刷)を実行し、結果(描画された行数、列幅、拡大後の大きさ、検索の一致数、印刷の呼び出し)が一致することを確認した。分子構造と 3D モデルは描画結果の画像を画素単位で比較し、更新前後で全画素が一致した。

Deployment Notes

  • unoserver イメージを別コンテナで起動し、MFR に UNOSERVER_EXTENSION_CONFIG_HOST・UNOSERVER_EXTENSION_CONFIG_PORT(既定 127.0.0.1:2003)を設定する。
  • MFR の Celery ワーカー(python3 -m invoke celery)を起動する。ブローカーは TASKS_CONFIG_BROKER_URL。
  • RabbitMQ を他アプリケーションと共有する構成では control_exchange の既定値(mfr)のままでよい。vhost を分けている場合は不要。
  • RDM-osf.io の docker-compose.yml の mfr_requirements は Python 3.5 のパスで invoke install を実行しているため、site-packages と /usr/local/bin をボリュームへコピーする方式に変更し、mfr_worker と unoserver のサービスを追加する必要がある。E2E では setup_rdm.sh の上書きで対応している。
  • イメージのビルド時に、npm レジストリと GitHub(PDF.js のリリースアーカイブ。SHA-256 を package.json に固定)へのアクセスが必要になる。
  • PDF ビューアの画面構造が変わるため、ファイルプレビューの E2E テストは、画面構造を判定して確認する RDM-e2e-test-nb feature/mfr-python313(282bffb)が必要になる。同ブランチのテストは更新前の MFR イメージでも通る。

felliott and others added 30 commits July 1, 2020 15:31
 * Add four new switches/envvars to manage keen logging:

   * `KEEN_ENABLE_LOGGING` will turn on/off *all* keen logging.

   * `KEEN_PRIVATE_LOG_VIEWS` will set logging for views to the
     private collection.

   * `KEEN_PRIVATE_LOG_ERRORS` will set logging for errors to the
     private collection.

   * `KEEN_PUBLIC_LOG_VIEWS` will set logging for views to the public
     collection.
* The python module `certifi` was pinned to a very old version to
   work around issues with Rackspace. Not only is it no longer
   relevant, it can no longer successfully validate modern TLS certs
 * conversion based off @aaxelb's work in @CenterForOpenScience/SHARE

 * update CI badge urls in README.md

 * add explicit upload to coveralls

   * replace python-coveralls with coveralls in dev-requirements.txt

 * remove old travis config files

 [ENG-3265]
 * Allow the parent window of the MFR iframe to pass its own url when
   starting the hypothes.is annotator. Parents using `postMessage`
   must now send an object with two keys: `type: 'startHypothesis'`
   and `parentUrl: <parent window url>`. Parents using pym must now
   call `.sendMessage('setParentUrl', <parent window url>)`. The
   included pym code has been updated to do this.

   MFR overrides the annotator to pass the parent window's url rather
   than its own, b/c the parent window url is more stable and
   descriptive. It was previously doing this by calling
   `document.referrer` from within the iframe. Due to privacy
   concerns, browsers have started allowing the iframe to only see the
   host and not the path of the parent url. Parent frames must now
   pass in their own url to get around this.
 * Upgrade Dockerfile image base to python v3.6.

 * Install gosu via apt-get. gosu v1.10 started being shipped with
   debian as of the `stretch` release.  Install from apt-get instead
   of `curl`-ing it from the github release page.

 * Pin pip version to 18.1 to avoid dep conflicts.

 * Based off the following WB commits:
   * CenterForOpenScience/waterbutler@d03a84c
   * CenterForOpenScience/waterbutler@b179eb8
 * Bump reportlab dep to v3.6.5 to unbreak `invoke install` on macOS.
 * add boa to supported extensions

 * bump pygments dep to 2.12 to support boa

 * add debugging logs to codepygments extension
… runtime stages, move LibreOffice into a separate unoserver image (Dockerfile.unoserver) built on Ubuntu 26.04 because Debian 13 links LibreOffice against libxml2 2.9.14 whose open CVEs cannot be fixed there (the fixed 2.15 changed ABI) and without the unused pebble binary the Ubuntu base image ships, apply security updates, copy the nbconvert templates into the runtime image and verify the dependency tree with pip check
…age image and scan both the mfr and unoserver images with Trivy
…dt/ods with Japanese text) and run them in CI against the unoserver image
…cies: Pillow 13.0.0, mistune, Mako, nbconvert 7.17.2, psd-tools, Jinja2, Markdown, Pygments and ipython to versions with security fixes, propcache 0.5.4 (0.4.0 was yanked for a reference leak) and the unpinned transitive libraries (urllib3, pyasn1, soupsieve, bleach, idna, multidict) to their current releases; move black/isort/ruff to the dev group, port PSD export to PSDImage.open().composite() and drop the stray scikit-image test import
… of the original URL and keep the response open for streaming; add provider download tests
…Keen analytics when no project id is configured; add HTTP provider tests
…ar) and close it on shutdown instead of leaking a session per request
…s with asyncio.sleep so the event loop keeps serving requests, and give the worker its own control exchange so it does not receive pickle control messages from other applications sharing the broker
…andlers only answer GET, but tornado parses form bodies before the method check
@miyamoto83
miyamoto83 force-pushed the feature/vuln-remediation-cos-wb branch from 8f8e292 to 7b6a7be Compare October 29, 2026 08:54
@miyamoto83 miyamoto83 changed the title [WIP][GRDM-63591] Python 3.13・依存ライブラリの更新と unoserver コンテナの分離(第1段階) [GRDM-63591] Python 3.13・依存ライブラリの更新と unoserver コンテナの分離(第1段階) Oct 30, 2026
@miyamoto83 miyamoto83 changed the title [GRDM-63591] Python 3.13・依存ライブラリの更新と unoserver コンテナの分離(第1段階) [WIP][GRDM-63591] Python 3.13・依存ライブラリの更新と unoserver コンテナの分離(第1段階) Oct 30, 2026
…nstead of the rpc backend, whose shared reply queue leaves results of earlier tasks unacknowledged until RabbitMQ closes the channel and the next task call fails; pin the default in a test
@miyamoto83 miyamoto83 changed the title [WIP][GRDM-63591] Python 3.13・依存ライブラリの更新と unoserver コンテナの分離(第1段階) [GRDM-63591] Python 3.13・依存ライブラリの更新と unoserver コンテナの分離(第1段階) Oct 30, 2026
@yacchin1205 yacchin1205 changed the title [GRDM-63591] Python 3.13・依存ライブラリの更新と unoserver コンテナの分離(第1段階) [GRDM-63966] Python 3.13・依存ライブラリの更新と unoserver コンテナの分離(第1段階) Nov 2, 2026
@yacchin1205
yacchin1205 marked this pull request as ready for review November 2, 2026 06:15
@miyamoto83
miyamoto83 marked this pull request as draft November 6, 2026 08:02
… 1.10.1 and prototype HTML pages under the pdf extension, and the GLmol/three.js files and the foundation/jquery-ui/qunit stylesheets under the pdb extension, none of which any template loads
… out since the extension was added in 2015, so .svg files are converted through unoconv and the extension's template and bundled SVGInjector 1.1.3-RC are never served
… Bootstrap 3.3.5 and jquery-mousewheel 3.1.13 in package.json, copy the served files from node_modules into the static directories with `invoke assets` during the Docker build instead of keeping copies in the repository (the server copy of the Bootstrap stylesheet was 3.3.4 and now matches the 3.3.5 script), and test that every file the templates load exists
…2.4.45 from npm together with the jquery.event.drag plugin it ships (the bundled 2.2 copy does not load under jQuery 3); replace the image viewer's removed load() event shorthand with on("load"), and check that the files the stylesheets refer to exist
…m npm (jQuery Zoom, pv with its gl-matrix build and JSC3D) in a CycloneDX SBOM so image scans see them, and test that the paths it records exist
@miyamoto83
miyamoto83 force-pushed the feature/vuln-remediation-cos-wb branch from f85b12e to 514853d Compare November 10, 2026 15:32
…on 2 and invoke problems it describes cannot occur with the Poetry-based setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.